package generator;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import util.IConstant;
import util.chessworld.Domain;

public class Generator extends Domain implements IConstant {

    private List<Move> moveList;
    private Position position;
    private int trait;
    private int[] formsOld, colorsOld;
    private int[] forms, colors;
 

    public Generator() {
        super();
        position = new Position();
        trait = position.trait();
        forms = position.getForm();
        colors = position.getColor();
        moveList = new ArrayList<Move>();
        searchMove();
    }

    public Generator(String positionS) {
        super();
        trait = position.trait();
        position = new Position(positionS);
        moveList = new ArrayList<Move>();
        searchMove();
    }

   
    private void simuleMove(int from, int to) {
        formsOld = Arrays.copyOf(forms, forms.length);
        colorsOld = Arrays.copyOf(colors, colors.length);
        forms[to] = forms[from];
        colors[to] = colors[from];
//        forms[from] = NONE;
//        colors[from] = NONE;
        isValidMove();
    }

    private void undoMove() {
        forms = Arrays.copyOf(formsOld, formsOld.length);
        colors = Arrays.copyOf(colorsOld, colorsOld.length);
    }

    private void isValidMove() {
    }

    private void searchMove() {
       zigzag(Av);
//        System.exit(0);
        for (Integer index : forms) {
            int p = forms[index];
            int c = colors[index];
            // couleur du trait 
            if (c == trait) {
                switch (p) {
//                    case NONE:
//                        break;
//                    case KING:
//                        king(index);
//                        break;
//                    case QUEEN:
//                        queen(index);
//                        break;
//                    case ROOK:
//                        rook(index);
//                        break;
//                    case BISHOP:
//                        bishop();
//                        break;
//                    case KNIGHT:
//                        knight();
//                        break;
//                    case PAWN:
//                        pawn();
//                        break;
//                    default:
//                        break;
                }
            }

        }
    }

    public List<Move> getMoveList() {
        return moveList;
    }

    private void king(int index) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private void queen(int index) {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private void rook(int index) {
    }

    private void bishop() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private void knight() {
        throw new UnsupportedOperationException("Not yet implemented");
    }

    private void pawn() {
        throw new UnsupportedOperationException("Not yet implemented");
    }
}











